home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / util / misc / 0VBRRun.lha / 0VBRRun1.0 / 0VBRRun.s < prev   
Text File  |  1999-02-06  |  3KB  |  166 lines

  1. ; ===========================================================================
  2. ; Run a program with the VBR set to 0, (CLI, MC68010 & OS39+ only)
  3. ;
  4. ; Created: Tue/3/Nov/1998
  5. ;
  6. ; Copyright © 1998-1999 Andrew Bell
  7. ;
  8. ; e-mail: andrew@ab2000.freeserve.co.uk (Put 0VBRRun in the subject)
  9. ;
  10. ; params: 0VBRRun [File]
  11. ; ===========================================================================
  12.  
  13.         IFD    _PHXASS_
  14.  
  15.         MC68020
  16.         SYMDEBUG
  17.         OUTPUT    0VBRRun
  18.         OPT    3
  19.  
  20.         ENDC
  21.  
  22. VERSION        MACRO
  23.         dc.b    "1.0"
  24.         ENDM
  25.  
  26. DATE        MACRO
  27.         dc.b    "6.2.99"
  28.         ENDM
  29.  
  30. YEAR        MACRO
  31.         dc.b    "1999"
  32.         ENDM
  33.  
  34.         INCDIR    AInc:
  35.         INCLUDE    mymacros.i
  36.         INCLUDE    system.i
  37.  
  38. ; ===========================================================================
  39.  
  40. slibc        MACRO            ; lib call and setup a6
  41.         move.l    \1,a6
  42.         jsr    _LVO\2(a6)
  43.         ENDM
  44.  
  45. libc        MACRO            ; lib call
  46.         jsr    _LVO\1(a6)
  47.         ENDM
  48.  
  49. ; ===========================================================================
  50.  
  51. Base:        move.w    d0,d2
  52.         move.l    a0,a2
  53.  
  54.         moveq    #20,d4            ; return code
  55.  
  56.         move.l    (4).w,a6        ; We need 010+ for VBR stuff
  57.         move.w    AttnFlags(a6),d0
  58.         btst.w    #AFB_68010,d0
  59.         beq    .Exit2DOS
  60.  
  61.         lea    DOSName(pc),a1
  62.         moveq    #39,d0
  63.         libc    OpenLibrary
  64.         move.l    d0,d7
  65.         beq    .Exit2DOS
  66.  
  67.         moveq    #0,d4
  68.         move.l    a6,d6
  69.  
  70.         lea.l    txt_Title(pc),a0
  71.         suba.l    a1,a1
  72.         bsr    Print
  73.  
  74.         cmp.b    #'?',(a2)
  75.         beq    .PrintUsage
  76.  
  77.         subq.w    #1,d2
  78.         bne    .ArgsOK
  79.  
  80. .PrintUsage    lea    txt_Usage(pc),a0
  81.         suba.l    a1,a1
  82.         bsr    Print
  83.         bra    .ExitCloseDOS
  84.  
  85. .ArgsOK        clr.b    (a2,d2.w)        ; Not OS friendly!
  86.  
  87.         bsr    ClearVBR
  88.         move.l    d0,d5
  89.  
  90.         move.l    #TAG_DONE,-(sp)        ; Run the program
  91.         move.l    a2,d1
  92.         move.l    sp,d2
  93.         slibc    d7,SystemTagList
  94.         addq.l    #4,sp
  95. .FixVBR        move.l    d5,d1
  96.         bsr    SetVBR
  97.  
  98.         tst.l    d0
  99.         beq    .ExitCloseDOS
  100.  
  101.         moveq    #20,d4
  102.  
  103.         lea    txt_LaunchFail(pc),a0
  104.         suba.l    a1,a1
  105.         bsr    Print
  106.  
  107. .ExitCloseDOS    move.l    d7,a1
  108.         slibc    d6,CloseLibrary
  109.  
  110. .Exit2DOS    move.l    d4,d0            ; Back to system
  111.         rts
  112.  
  113. ClearVBR    PUSH    d1/a5/a6        ; d6=Execbase
  114.  
  115.         move.l    d6,a6
  116.         lea.l    super_ClearVBR(pc),a5
  117.         jsr    -30(a6)            ; Supervisor
  118.  
  119.         PULL    d1/a5/a6
  120.         rts
  121.  
  122. super_ClearVBR    movec    VBR,d0
  123.         moveq    #0,d1
  124.         movec    d1,VBR
  125.         nop
  126.         rte                ; Return old VBR in d0
  127.  
  128. SetVBR        PUSH    a5/a6            ; d1=VBR, d6=ExecBase
  129.         move.l    d6,a6
  130.         lea.l    super_SetVBR(pc),a5
  131.         jsr    -30(a6)            ; Supervisor
  132.         PULL    a5/a6
  133.         rts
  134.  
  135. super_SetVBR    movec    d1,VBR
  136.         nop
  137.         rte
  138.  
  139. Print        PUSH    a0-a1/d0-d2/a6    ; A0=String, A1=Fmt, d7=DOSBase
  140.  
  141.         move.l    a0,d1
  142.         move.l    a1,d2
  143.         slibc    d7,VPrintf
  144.  
  145.         PULL    a0-a1/d0-d2/a6
  146.         rts
  147.  
  148. ; ===========================================================================
  149.  
  150. txt_VTag    dc.b    0,"$VER: 0VBRRun "
  151.         VERSION
  152.         dc.b    " ("
  153.         DATE
  154.         dc.b    ")",0
  155.  
  156. txt_Title    dc.b    "0VBRRun "
  157.         VERSION
  158.         dc.b    " Copyright © "
  159.         YEAR
  160.         dc.b    " Andrew Bell\n",0
  161.  
  162. txt_LaunchFail    dc.b    "Failed to launch program!\n",0
  163. txt_Usage    dc.b    "Usage: 0VBRRun [File]\n",0
  164.  
  165. DOSName        dc.b    "dos.library",0
  166.